<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>Linux编译安装PHP+Nginx+Mysql | SmileYi</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="获取相关软件包1234567891011121314151617# 下载nginxwget -c http://resource.smileyi.cn/linux/nginx-1.5.13.tar.gz# 下载pcrewget -c http://resource.smileyi.cn/linux/pcre-8.35.tar.gz# 下载MySQLwget -c http://resource.s">
<meta name="keywords" content="原创">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux编译安装PHP+Nginx+Mysql">
<meta property="og:url" content="http://smileyi.gitee.io/2019/04/07/Linux编译安装PHP-Nginx-Mysql/index.html">
<meta property="og:site_name" content="SmileYi">
<meta property="og:description" content="获取相关软件包1234567891011121314151617# 下载nginxwget -c http://resource.smileyi.cn/linux/nginx-1.5.13.tar.gz# 下载pcrewget -c http://resource.smileyi.cn/linux/pcre-8.35.tar.gz# 下载MySQLwget -c http://resource.s">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-04-07T13:18:04.005Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux编译安装PHP+Nginx+Mysql">
<meta name="twitter:description" content="获取相关软件包1234567891011121314151617# 下载nginxwget -c http://resource.smileyi.cn/linux/nginx-1.5.13.tar.gz# 下载pcrewget -c http://resource.smileyi.cn/linux/pcre-8.35.tar.gz# 下载MySQLwget -c http://resource.s">
  
    <link rel="alternate" href="/atom.xml" title="SmileYi" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">SmileYi</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">只要学会破罐子破摔 世界就会豁然开朗</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">首页</a>
        
          <a class="main-nav-link" href="/archives">归档</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://smileyi.gitee.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-Linux编译安装PHP-Nginx-Mysql" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/04/07/Linux编译安装PHP-Nginx-Mysql/" class="article-date">
  <time datetime="2019-04-07T12:57:45.000Z" itemprop="datePublished">2019-04-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Linux/">Linux</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Linux编译安装PHP+Nginx+Mysql
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="获取相关软件包"><a href="#获取相关软件包" class="headerlink" title="获取相关软件包"></a>获取相关软件包</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"># 下载nginx</span><br><span class="line">wget -c http://resource.smileyi.cn/linux/nginx-1.5.13.tar.gz</span><br><span class="line"></span><br><span class="line"># 下载pcre</span><br><span class="line">wget -c http://resource.smileyi.cn/linux/pcre-8.35.tar.gz</span><br><span class="line"></span><br><span class="line"># 下载MySQL</span><br><span class="line">wget -c http://resource.smileyi.cn/linux/mysql-5.6.11.tar.gz</span><br><span class="line"></span><br><span class="line"># 下载PHP</span><br><span class="line">wget -c http://resource.smileyi.cn/linux/php-7.2.tar.gz  </span><br><span class="line"></span><br><span class="line"># 下载cmake（MySQL编译工具） </span><br><span class="line">wget -c http://resource.smileyi.cn/linux/cmake-2.8.8.tar.gz</span><br><span class="line"></span><br><span class="line">#下载libmcrypt（PHPlibmcrypt模块） </span><br><span class="line">wget -c http://resource.smileyi.cn/linux/libmcrypt-2.5.8.tar.gz</span><br></pre></td></tr></table></figure>
<h4 id="安装编译工具及运行库"><a href="#安装编译工具及运行库" class="headerlink" title="安装编译工具及运行库"></a>安装编译工具及运行库</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"># Centos</span><br><span class="line">yum install make apr* autoconf automake curl-devel \</span><br><span class="line">    gcc gcc-c++ zlib-devel openssl openssl-devel \</span><br><span class="line">    pcre-devel gd kernel keyutils patch perl \</span><br><span class="line">    kernel-headers compat* mpfr cpp glibc libgomp \</span><br><span class="line">    libstdc++-devel ppl cloog-ppl keyutils-libs-devel \</span><br><span class="line">    libcom_err-devel libsepol-devel  libselinux-devel \</span><br><span class="line">    krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* \</span><br><span class="line">    php-common php-gd ncurses* libtool* libxml2 \</span><br><span class="line">    libxml2-devel patch freetype-devel</span><br><span class="line"></span><br><span class="line"># Ubuntu</span><br><span class="line">sudo apt install libwrap0-dev libncurses5-dev libssl-dev \</span><br><span class="line">    libxml2-dev libsslcommon2-dev libcurl4-openssl-dev \</span><br><span class="line">    pkg-config libbz2-dev libjpeg-dev libpng12-dev libxpm-dev \</span><br><span class="line">    libfreetype6-dev libmcrypt-dev libxslt1-dev libiconv-hook-dev \</span><br><span class="line">    libpcre3-dev gcc g++</span><br></pre></td></tr></table></figure>
<h4 id="安装cmake"><a href="#安装cmake" class="headerlink" title="安装cmake"></a>安装cmake</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf cmake-2.8.8.tar.gz </span><br><span class="line">cd cmake-2.8.8</span><br><span class="line">./configure --prefix=/usr/local/cmake</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h4 id="安装Mysql"><a href="#安装Mysql" class="headerlink" title="安装Mysql"></a>安装Mysql</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf mysql-5.6.11.tar.gz</span><br><span class="line">cd mysql-5.6.11 </span><br><span class="line">cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \</span><br><span class="line">    -DMYSQL_DATADIR=/usr/local/mysql/data　　</span><br><span class="line">make　</span><br><span class="line">make install　　</span><br><span class="line">cd /usr/local/mysql</span><br><span class="line"></span><br><span class="line"># 创建mysql用户</span><br><span class="line">useradd mysql -M</span><br><span class="line"></span><br><span class="line"># 生成mysql系统数据库</span><br><span class="line">./scripts/mysql_install_db --basedir=/usr/local/mysql \</span><br><span class="line">    --datadir=/usr/local/mysql/data --user=mysql</span><br><span class="line"></span><br><span class="line"># 把Mysql加入系统启动　</span><br><span class="line">cp ./support-files/mysql.server /etc/init.d/mysqld</span><br><span class="line"></span><br><span class="line"># 加入开机启动</span><br><span class="line">chkconfig mysqld on </span><br><span class="line"></span><br><span class="line"># 删除系统默认配置文件/etc/my.cnf</span><br><span class="line">rm /etc/my.cnf</span><br><span class="line"></span><br><span class="line"># 设置root密码</span><br><span class="line">mysql -uroot  </span><br><span class="line">mysql&gt; SET PASSWORD = PASSWORD(&apos;root&apos;);</span><br><span class="line"></span><br><span class="line"># 赋予mysql root用户权限</span><br><span class="line">sudo /usr/local/mysql/bin/mysql_upgrade -uroot -proot</span><br></pre></td></tr></table></figure>
<h4 id="安装pcre"><a href="#安装pcre" class="headerlink" title="安装pcre"></a>安装pcre</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf pcre-8.35.tar.gz</span><br><span class="line">cd pcre-8.35</span><br><span class="line">./configure --prefix=/usr/local/pcre </span><br><span class="line">make </span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h4 id="安装nginx"><a href="#安装nginx" class="headerlink" title="安装nginx"></a>安装nginx</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">useradd nginx -M</span><br><span class="line">tar zxvf nginx-1.5.13.tar.gz</span><br><span class="line">cd nginx-1.5.13</span><br><span class="line">./configure --prefix=/usr/local/nginx \</span><br><span class="line">    --without-http_memcached_module \</span><br><span class="line">    --user=nginx --group=nginx \</span><br><span class="line">    --with-http_stub_status_module \</span><br><span class="line">    --with-http_ssl_module</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h4 id="安装libmcrypt"><a href="#安装libmcrypt" class="headerlink" title="安装libmcrypt"></a>安装libmcrypt</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tar zxvf libmcrypt-2.5.8.tar.gz</span><br><span class="line">cd libmcrypt-2.5.8</span><br><span class="line">./configure</span><br><span class="line">make</span><br><span class="line">nake install</span><br></pre></td></tr></table></figure>
<h4 id="安装PHP"><a href="#安装PHP" class="headerlink" title="安装PHP"></a>安装PHP</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">tar -zvxf php-7.2.tar.gz</span><br><span class="line">cd php-7.2</span><br><span class="line">mkdir -p /usr/local/php</span><br><span class="line">./configure --prefix=/usr/local/php \</span><br><span class="line">    --with-config-file-path=/usr/local/php/etc \</span><br><span class="line">    --with-mysql-sock=/var/run/mysql/mysql.sock \</span><br><span class="line">    --with-mhash \</span><br><span class="line">    --with-openssl \</span><br><span class="line">    --with-mysqli=shared,mysqlnd \</span><br><span class="line">    --with-pdo-mysql=shared,mysqlnd \</span><br><span class="line">    --with-gd \</span><br><span class="line">    --with-iconv \</span><br><span class="line">    --with-zlib \</span><br><span class="line">    --enable-zip \</span><br><span class="line">    --enable-inline-optimization \</span><br><span class="line">    --disable-debug \</span><br><span class="line">    --disable-rpath \</span><br><span class="line">    --enable-shared \</span><br><span class="line">    --enable-xml \</span><br><span class="line">    --enable-bcmath \</span><br><span class="line">    --enable-shmop \</span><br><span class="line">    --enable-mbstring \</span><br><span class="line">    --enable-pcntl \</span><br><span class="line">    --enable-sockets \</span><br><span class="line">    --with-xmlrpc \</span><br><span class="line">    --enable-soap \</span><br><span class="line">    --without-pear \</span><br><span class="line">    --with-gettext \</span><br><span class="line">    --enable-session \</span><br><span class="line">    --with-curl \</span><br><span class="line">    --with-jpeg-dir \</span><br><span class="line">    --with-freetype-dir \</span><br><span class="line">    --enable-fpm \</span><br><span class="line">    --enable-fastcgi \</span><br><span class="line">    --with-fpm-user=php \</span><br><span class="line">    --with-fpm-group=php</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://smileyi.gitee.io/2019/04/07/Linux编译安装PHP-Nginx-Mysql/" data-id="ck5390nr10008keczi4w24iq6" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/原创/">原创</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/04/09/Base64算法原理/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          Base64算法原理
        
      </div>
    </a>
  
  
    <a href="/2019/04/05/PHP编译参数/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">PHP编译参数</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Docker/">Docker</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Linux/">Linux</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/MacOS/">MacOS</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Mysql/">Mysql</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Nginx/">Nginx</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/PHP/">PHP</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Swoole/">Swoole</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/算法/">算法</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/网络/">网络</a><span class="category-list-count">1</span></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/原创/">原创</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/总结/">总结</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/笔记/">笔记</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/转载/">转载</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/01/">一月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">4</span></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/01/05/Swoole之server/">swoole之server</a>
          </li>
        
          <li>
            <a href="/2020/01/02/Certbot-免费的ssl证书/">Certbot--免费的ssl证书</a>
          </li>
        
          <li>
            <a href="/2019/07/13/Nginx限流配置/">Nginx限流配置</a>
          </li>
        
          <li>
            <a href="/2019/06/23/Mysql分区/">Mysql分区</a>
          </li>
        
          <li>
            <a href="/2019/04/15/Rsa算法/">Rsa算法</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 王中艺<br>
      <a href="http://www.beian.miit.gov.cn/">京ICP备18032247号-2</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">首页</a>
  
    <a href="/archives" class="mobile-nav-link">归档</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>